home *** CD-ROM | disk | FTP | other *** search
/ Interactive Web Graphics with Shout 3D / Interactive Web Graphics With Shout 3D.iso / pc / Shout3Ddemo / Shout3d_runtime / codebase / custom_nodes / InvertSceneEffect.java < prev    next >
Text File  |  2000-09-21  |  1KB  |  38 lines

  1. /**    
  2.     Company:        Eyematic Interfaces
  3.     Project:        Shout3D 2.0 Sample Code
  4.     Class:            InvertSceneEffect
  5.     Date:            March 23, 2000
  6.     Description:    A simple example of a PostRenderEffect that inverts the colors of the scene.
  7.     (C) Copyright Eyematic Interfaces, Inc. - 1997-2000 - All rights reserved
  8.  */
  9.  
  10. package custom_nodes;
  11. import shout3d.core.*;
  12. import shout3d.*;
  13. import java.awt.Graphics;
  14.  
  15. /**
  16.  * InvertSceneEffect
  17.  * 
  18.  * @author Dave Westwood
  19.  */
  20.  
  21. public class InvertSceneEffect extends PostRenderEffect {
  22.  
  23.     /**
  24.      * Constructs a default InvertSceneEffect node.
  25.      */
  26.     public InvertSceneEffect(){}
  27.     
  28.     public void filter(Graphics offScreenGraphics, int surface_pixel_bits[], float z_buffer[], int deviceWidth, int deviceHeight){
  29.         if (surface_pixel_bits == null)
  30.             return;
  31.         for (int i=0;i<surface_pixel_bits.length;i++){
  32.             surface_pixel_bits[i] = 0xff000000 + 
  33.                                     ((255-((surface_pixel_bits[i]>>16)&0xff))<<16) +    // invert red
  34.                                     ((255-((surface_pixel_bits[i]>>8)&0xff))<<8) +      // invert green
  35.                                     ((255-((surface_pixel_bits[i])&0xff)));             // invert blue
  36.         }
  37.     }
  38. }